package com.gitee.wsl.struct.grammar.node.expr.stmt

import com.gitee.wsl.struct.grammar.node.expr.IExp
import com.gitee.wsl.struct.grammar.node.expr.IStmt
import com.gitee.wsl.struct.grammar.node.expr.closure.IClosureScope
import com.gitee.wsl.struct.grammar.node.expr.semantic.ISemanticRecorder
import com.gitee.wsl.struct.grammar.node.expr.type.KeywordType
import com.gitee.wsl.struct.grammar.node.expr.type.OperatorType

/**
 * 【语义分析】异常处理语句
 *
 * @author bajdcc
 */
class StmtThrow(var exp: IExp) : IStmt {

    override fun analysis(recorder: ISemanticRecorder) {
        exp.analysis(recorder)
    }

    /*override fun genCode(codegen: ICodegen) {
        exp.genCode(codegen)
        codegen.genCode(RuntimeInst.ithrow)
    }*/

    override fun toString(): String {
        return print(StringBuilder())
    }

    override fun print(prefix: StringBuilder): String {
        return prefix.toString() +
                KeywordType.THROW.desc +
                " " +
                exp.print(prefix) +
                OperatorType.SEMI.desc
    }

    override fun addClosure(scope: IClosureScope) {
        exp.addClosure(scope)
    }
}